Repository navigation
Conversation
remember it once for all threads, so a host signal still reaches its handler if it lands on a different PHP thread
|
4 core workload:
Benchmarked and table generated by gpt, but I got very similar numbers in manual wrk runs, so I think it's more or less correct in the realm of local hardware not being the most stable.
cc @Girgias |
iliaal
left a comment
There was a problem hiding this comment.
Please fix the NTS timeout regression before merging. I’d also like deployments with a tight pending-signal limit to be able to keep execution timers enabled without retaining them between requests.
| static const struct itimerspec disarmed = {0}; | ||
| zend_cached_timer *cache = TIMER_CACHE; | ||
| if (cache && cache->pid == EG(pid) && CAN_CACHE_TIMER() | ||
| && timer_settime(EG(max_execution_timer_timer), 0, &disarmed, NULL) == 0) { |
There was a problem hiding this comment.
A disarmed timer still consumes one RLIMIT_SIGPENDING slot for the real UID. With the limit set to 1, two php -S processes under the same UID can serve one request each, sequentially, on master. Here the first server keeps the slot while idle, and the second fails at request startup with EAGAIN.
| --FILE-- | ||
| <?php | ||
| include "php_cli_server.inc"; | ||
| php_cli_server_start(<<<'PHP' |
There was a problem hiding this comment.
Please set PHP_CLI_SERVER_WORKERS= in --ENV--, as serialization_context_request_reset.phpt does. With four workers, this test passed with both busy requests on one PID and the intervening idle request on another.
Isn't the limit ridiculously high on Linux? That's the reason it's only enabled there. I could check limits on init once before but what's really a sane number where we say reuse is ok? If we check it per request against the currently active number of threads, I would imagine it's going to eat the savings of reusing them. |
|
The limit is high here too, and other processes under the same real UID share it. I’d keep reuse on by default and let admins disable just reuse at startup. That avoids both a threshold and a per-request check. |
|
So I figured out why it's so high on linux and it's because it uses RLIMIT_NPROC, i.e. how many processes can exist at a time. Since fpm doesn't check the rlimit for whether it can fork X children, I don't think it's worth an extra setting here either. What I still want to do here though is maybe not disarm and already disarmed timer. The other two comments look sensible and I'll change it. |
logic on master: each request creates a timer, sets time limit, deletes the timer
logic here: each thread creates a timer, each request sets time limit, then after the request sets time limit to zero. timer is reused by the next request.
this skips noticeable overhead, especially in threaded scenarios (first measurement in frankenphp ~4% for hello world), but also in NTS (if max execution timers are enabled)
FreeBSD excluded for now because of https://github.com/freebsd/freebsd-src/blob/main/sys/sys/timers.h#L65
cc @dunglas